package cn.rjtraining.service.impl;

import java.util.List;
import java.util.Map;

import cn.rjtraining.model.Course;
import cn.rjtraining.model.Student;
import cn.rjtraining.service.StudentService;
import cn.rjtraining.util.DbUtil;
import cn.rjtraining.util.MyBeanUtils;

public class StudentServiceImpl implements StudentService {

	public List<Student> list(Student student) {
		String sql = "SELECT sno,sname,sex,classes from student WHERE sno like ? AND classes=? AND sname LIKE ? ;";
		List<Map<String, Object>> datasMap = DbUtil.executeQuery(sql, "%"
				+ student.getSno() + "%", student.getClasses(), "%"
				+ student.getSname() + "%");
		return MyBeanUtils.convertMap(Course.class, datasMap);
	}

	public int save(Student student) {
		// TODO Auto-generated method stub
		String sql = "INSERT INTO student(sno,sname,sex,age,classes) VALUES(?,?,?,?,?);";
		return DbUtil.executeUpdate(sql, student.getSno(), student.getSname(),
				student.getSex(), student.getSex(), student.getClasses());
	}

}
